For each of the following examples:
X (treatment of interest) to Y (outcome of interest).X on Y. You can use dagitty.net to help you, but you should start trying to recognize these on your own!r using ggdag. After setting up the dag with dagify() (and specifying exposure and outcome inside dagify), pipe that into ggdag(). Try again piping it instead into ggdag_status() (to highlight what is X and what is Y). Try again piping it instead into ggdag_adjustment_set() to show what needs to be controlled.Don’t forget to install ggdag!
Pathways:
\(Z\) needs to be controlled for, since it is opening a backdoor path.
dag1 <- dagify(Y ~ X + Z,
X ~ Z,
exposure = "X",
outcome = "Y")
dag1 %>%
ggdag_status(seed = 1)+
theme_dag_blank()dag1 %>%
ggdag_paths(seed = 1)+
theme_dag_blank()dag1 %>%
ggdag_adjustment_set()+
theme_dag_blank()Pathways:
Nothing should be controlled for, since \(M\) is a mediator, and part of the effect of \(X\) on \(Y\)
dag2 <- dagify(Y ~ X + M,
M ~ X,
exposure = "X",
outcome = "Y")
dag2 %>%
ggdag_status(seed = 1)+
theme_dag_blank()dag2 %>%
ggdag_paths(seed = 1)+
theme_dag_blank()dag2 %>%
ggdag_adjustment_set()+
theme_dag_blank()Pathways:
Backdoor path 3 is closed by the collider at \(Z\). Backdoor path 2 remains open, so we need to control for \(A\). (If we blocked \(Z\) to close path 2, that would open up backdoor path 3!) Only \(A\) should be controlled for.
Alternatively, we could control for \(B\) and \(Z\).
dag3 <- dagify(Y ~ X + Z + B,
Z ~ B + A,
X ~ A,
exposure = "X",
outcome = "Y")
dag3 %>%
ggdag_status(seed = 1)+
theme_dag_blank()dag3 %>%
ggdag_paths(seed = 1)+
theme_dag_blank()dag3 %>%
ggdag_adjustment_set()+
theme_dag_blank()Pathways:
Path 2 is a front door path we want to leave open. Backdoor path 3 is closed by the collider at \(Z\). Nothing needs to be controlled for!
dag4 <- dagify(Y ~ X + B + C,
Z ~ B + A,
X ~ A,
C ~ X,
exposure = "X",
outcome = "Y")
dag4 %>%
ggdag_status(seed = 1)+
theme_dag_blank()dag4 %>%
ggdag_paths(seed = 1)+
theme_dag_blank()dag4 %>%
ggdag_adjustment_set()+
theme_dag_blank()Pathways:
Path 2 is a front door path we want to leave open. Backdoor path 3 is closed by the collider at \(Z\). Backdoor path 4 is closed by the collider at \(Z\). We don’t want to control for anything!
dag5 <- dagify(Y ~ X + Z + A,
Z ~ X + A + B,
B ~ A,
exposure = "X",
outcome = "Y")
dag5 %>%
ggdag_status(seed = 1)+
theme_dag_blank()dag5 %>%
ggdag_paths(seed = 1)+
theme_dag_blank()dag5 %>%
ggdag_adjustment_set()+
theme_dag_blank()